<div class="portlet box grey">
    <div class="portlet-title">
        <div class="caption">
            <a class="btn green float-left" href="<?php echo url_for('@customer_add') ?>"><span class="icon-plus"> Нэмэх</span></a>
        </div>
        <div class="tools">
            <a href="javascript:;" class="collapse"></a>
        </div>
        <form method="get" class="form-horizontal">
            <div class="control-group float-left">                
                <input name="name" value="<?php echo $name ?>"/>
            </div>
            <div class="control-group float-left">
                <button type="submit" class="btn btn-primary">
                    <i class="icon-filter icon-white"></i> Шүүх
                </button>
            </div>
        </form>
    </div>
    <div class="portlet-body">
        <div class="widget-box">
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th></th>
                        <th>Нэр</th>
                        <th>Овог</th>
                        <th>Утас</th>
                        <th>Имэйл</th>
                        <th>Худалдан авалт</th>
                        <th>Нийт дүн ₮</th>
                        <th>Сүүлийн худалдан авалт</th>
                        <th>Гишүүний тухай</th>
                        <th>Урамшуулал</th>
                        <th>Бүртгэсэн огноо</th>
                        <th>Бүртгэсэн ажилтан</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if ($rows): ?>
                        <?php foreach ($rows AS $row): ?>
                            <tr>
                                <td class="center" width="140">
                                    <?php echo link_to('<i class="icon-pencil tip-bottom"> Засах</i>', url_for('@customer_edit?id=' . $row['id']), array('class' => 'btn mini green')) ?>
                                    <?php if ($row['is_active'] == CustomerTable::ACTIVE): ?>
                                        <?php echo link_to('<i class="icon-trash tip-bottom"> Устгах</i>', '@customer_delete?id=' . $row['id'], array('confirm' => 'Та устгахдаа итгэлтэй байна уу?', 'class' => 'btn mini red')) ?>
                                    <?php elseif ($row['is_active'] == CustomerTable::PASSIVE): ?>
                                        <?php echo link_to('<i class="icon-refresh tip-bottom"> Сэргээх</i>', '@customer_restore?id=' . $row['id'], array('confirm' => 'Та сэргээхдээ итгэлтэй байна уу?', 'class' => 'btn mini blue')) ?>
                                    <?php endif; ?>
                                </td>
                                <td><?php echo $row['firstname'] ?></td>
                                <td><?php echo $row['lastname'] ?></td>
                                <td><?php echo $row['number'] ?></td>
                                <td><?php echo $row['email'] ?></td>
                                <td><?php echo $row['sales_count'] ?></td>
                                <td><?php echo $row['sales_total'] ?></td>
                                <td><?php echo $row['sales_last'] ?></td>
                                <td><?php echo $row['about'] ?></td>
                                <td><?php echo $row['bonus'] ?></td>
                                <td><?php echo $row['created_at'] ?></td>
                                <td><?php echo $row['username'] ?></td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="11">Гишүүн олдсонгүй</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
                <tfoot>
                    <tr>
                        <th colspan="11">Нийт <?php echo count($rows) ?> гишүүн байна</th>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>